package com.zhan.rkforum.util;


public class RedisKeyUtil {
    //分隔符
    private static final String SPLIT = ":";
    //点赞实体前缀
    private static final String PREFIX_ENTITY_LIKE = "like:entity";
    //点赞用户前缀
    private static final String PREFIX_USER_LIKE = "like:user";
    //粉丝前缀
    private static final String PREFIX_FOLLOWER = "follower";
    //关注实体前缀
    private static final String PREFIX_FOLLOWEE = "followee";
    //验证码前缀
    private static final String PREFIX_CHECK_CODE = "kaptcha";
    //登录凭证前缀
    private static final String PREFIX_TICKET = "loginTicket";
    //用户前缀
    private static final String PREFIX_USER = "user";
    //独立访客
    private static final String PREFIX_UV = "uv";
    //日活跃用户
    private static final String PREFIX_DAU = "dau";
    //贴子前缀
    private static final String PREFIX_POST = "post";



    /**
     * 获取点赞实体的key
     *
     * @param entityType 实体类型
     * @param entityId   实体的id
     * @return {@link String}
     */
    public static String  getEntityLikeKey(int entityType, int entityId){
        return PREFIX_ENTITY_LIKE + SPLIT + entityType +SPLIT + entityId;
    }

    /**
     * 获取用户获赞的key
     *
     * @param userId 用户id
     * @return {@link String}
     */
    public static String getUserLikeKey(int userId){
        return PREFIX_USER_LIKE + SPLIT + userId;
    }


    /**
     * 获取受关注用户的key
     *
     * @param entityId 用户id
     * @return {@link String}
     */
    //follower:3:15   --->Zset(粉丝Id，now)
    public static String getFollowerKey(int entityType, int entityId){
        return PREFIX_FOLLOWER + SPLIT + entityType + SPLIT + entityId;
    }


    /**
     * 获取关注的实体的key
     *
     * @param entityType 实体类型
     * @param userId   实体的id
     * @return {@link String}
     */
    //followee:12:1   ---> Zset(目标实体Id， Now)
    public static String getFolloweeKey(int entityType, int userId){
        return PREFIX_FOLLOWEE + SPLIT + userId + SPLIT + entityType;
    }

    /**
     * 获取验证码的key
     *
     * @param owner 老板
     * @return {@link String}
     */
    public static String getKaptchaKey(String owner){
        return PREFIX_CHECK_CODE + SPLIT + owner;
    }

    /**
     * 获取登录凭证的key
     *
     * @param ticket 登录凭证
     * @return {@link String}
     */
    public static String getTicketKey(String ticket){
        return PREFIX_TICKET + SPLIT + ticket;
    }

    /**
     * 获取用户的key
     *
     * @param userId 用户id
     * @return {@link String}
     */
    public static String getUserKey(int userId){
        return PREFIX_USER + SPLIT + userId;
    }

    /**
     * 单日独立访客量 key
     *
     * @param date 日期
     * @return {@link String}
     */
    public static String getUVKey(String date){
        return PREFIX_UV + SPLIT + date;
    }

    /**
     * 区间独立访客量 key
     *
     * @param start 开始
     * @param end   结束
     * @return {@link String}
     */
    public static String getUVKey(String start, String end){
        return PREFIX_UV + SPLIT + start + SPLIT + end;
    }

    /**
     * 单日活跃用户 key
     *
     * @param date 日期
     * @return {@link String}
     */
    public static String getDauKey(String date){
        return PREFIX_DAU + SPLIT + date;
    }

    /**
     * 区间活跃用户 key
     *
     * @param start 开始
     * @param end   结束
     * @return {@link String}
     */
    public static String getDauKey(String start, String end){
        return PREFIX_DAU + SPLIT + start + SPLIT + end;
    }

    public static String getPostScoreKey(){
        return PREFIX_POST + SPLIT + "score";
     }
}
